package main;

import book.BookList;
import user.Admin;
import user.user;
import user.NormalUser;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 东莞呵呵
 * Date:2022-05-19
 * Time:21:40
 */
public class Main {
    public static user login(){
        Scanner scanner =new Scanner(System.in);
        System.out.println("请输入你的姓名->");
        String name=scanner.nextLine();
        System.out.println("你好"+name+",欢迎来到图书管理系统!");
        System.out.println("1、管理员。2、普通用户");
        System.out.println("请输入你的身份->");

        while(true) {
            int choice=scanner.nextInt();
            if (choice == 1) {
                return new Admin(name);
            } else if (choice == 2) {
                return new NormalUser(name);
            }
            System.out.println("输入非法，请重新输入");
        }

    }
    public static void main(String[] args) {
        BookList bookList=new BookList();
        user user=login();
        while(true){
            int choice=user.menu();
            user.operation(choice,bookList);
            if(choice==0){
                break;
            }
        }
    }
}
